﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Internal.Master" Inherits="BPM.Web.ViewPage<BPM.ViewModel.CreatePurchaseOrderViewModel>" %>

<%@ Import Namespace="BPM" %>
<%@ Import Namespace="BPM.Entity" %>
<asp:Content ID="c1" ContentPlaceHolderID="TitleContent" runat="server">
	新建进货单
</asp:Content>
<asp:Content ID="c3" ContentPlaceHolderID="ScriptStyleContent" runat="server">
	<%
		var error = this.ViewData["Error"] as string;
		var initRows = this.ViewContext.HttpContext.Request.HttpMethod.ToLower() == "get";
	%>
	<script type="text/javascript">
	error = '<%:error %>';
	initRows = <%= initRows ? "true" : "false" %>;
	</script>
</asp:Content>
<asp:Content ID="c2" ContentPlaceHolderID="MainContent" runat="server">
	<%
		using (Html.BeginForm())
		{
	%>
	<%--这里用这个居然不是修改后的数据。
	<%: Html.HiddenFor(m => m.MaterialNumbers) %>--%>
	<input type="hidden" id="MaterialNumbers" name="MaterialNumbers" value="<%=this.Model.MaterialNumbers %>" />
	<p>
		进货单条码:
		<%: Html.DisplayTextFor(m => m.Barcode) %>
		<%: Html.HiddenFor(m => m.Barcode)%>
		创建者:
		<%: Html.DisplayTextFor(m => m.Creator) %>
		<%: Html.HiddenFor(m => m.Creator)%>
	</p>
	<div>
		<table id="materialTable" cellpadding="10">
			<thead>
				<tr>
					<td>
						物料型号
					</td>
					<td>
						数量
					</td>
					<td>
						交货日期
					</td>
					<td>
						付款方式
					</td>
					<td>
					</td>
				</tr>
			</thead>
			<tbody id="materialContainer">
				<%
					int i = 0;
					foreach (var material in this.Model.Materials)
					{
						i++;
				%>
				<tr id="tr_<%=i %>">
					<td style="text-align: center;">
						<input type="hidden" id="SelectedMaterialId_<%=i %>" value="<%=material.MaterialId %>" />
						<select id="BigCategoryId_<%=i %>">
						</select>
						<select id="CategoryId_<%=i %>">
						</select>
						<select name="MaterialId_<%=i %>" id="MaterialId_<%=i %>">
						</select>
					</td>
					<td>
						<input type="text" name="Numbers_<%=i %>" value='<%=material.Amount %>' />
					</td>
					<td>
						<input type="text" name="DeliveryTime_<%=i %>" value='<%=material.DeliveryTime %>'
							onclick="setday(this);" />
					</td>
					<td>
						<input type="text" name="PayMode_<%=i %>" value='<%=material.PaymentMode %>' />
					</td>
					<td>
						<a href="javascript:;" onclick="delMaterial(<%=i %>);">
							<img style="width: 16px; height: 16px;" src='<%=url("~/images/c/delete.png") %>'
								border="0" alt="删除" /></a>
					</td>
				</tr>
				<%
}
				%>
				<!--内容由JS添加-->
			</tbody>
		</table>
	</div>
	<p>
		<input type="button" value="添加物料" onclick="addMaterial()" />
		<input type="submit" value="提交" />
	</p>
	<%
		} 
	%>
</asp:Content>
